package senior.SuperMarket;

import java.util.Scanner;

/**
 * @author shkstart
 * @creat 2022-04-14:33
 */
public class Test {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        SuperMarket market = new SuperMarket("小蒋大超市", "合肥滨湖");
        System.out.println("超市信息：\n" + market.toString());
        a:
        while (true) {
            System.out.println("\t\t1.开卡 2.修改密码 3.兑换商品 4.查询积分 5.退出");
            System.out.print("请选择：");
            int num = sc.nextInt();
            switch (num) {
                case 1: {
                    System.out.println("---开卡---");
                    System.out.println("编号：");
                    String no = sc.next();
                    System.out.println("姓名：");
                    String name = sc.next();
                    System.out.println("手机号：");
                    String phone = sc.next();
                    System.out.println("积分：");
                    int jifen = sc.nextInt();
                    boolean b = market.addCustomer(new Customer(no, name, phone, jifen));
                    if(b){
                        System.out.println("开卡成功！");
                    }else {
                        System.out.println("开卡失败！");
                    }
                    break;
                }
                case 2: {
                    System.out.println("---修改密码---");
                    System.out.println("会员号：");
                    String no = sc.next();
                    System.out.println("密码：");
                    String pwd = sc.next();
                    System.out.println("输入新密码：");
                    String newPwd = sc.next();
                    boolean b = market.modification(no, pwd ,newPwd);
                    if(b){
                        System.out.println("密码修改成功！");
                    }else {
                        System.out.println("修改失败");
                    }
                    break;
                }
                case 3: {
                    System.out.println("---兑换商品---");
                    System.out.println("\t\t商品清单");
                    System.out.println("1.抽纸  2.电饭煲  3.洗衣机");
                    System.out.println("会员号：");
                    String no = sc.next();
                    System.out.println("商品序号：");
                    int choose = sc.nextInt();
                    String exchange = market.exchange(no, choose);
                    System.out.println(exchange);
                    break;
                }
                case 4: {
                    System.out.println("---查询积分---");
                    System.out.println("会员号：");
                    String no = sc.next();
                    int inquire = market.inquire(no);
                    if(inquire == -1){
                        System.out.println("找不到该会员");
                    }else {
                        System.out.println("剩余积分：" + inquire);
                    }
                    break;
                }
                case 5: {
                    System.out.println("退出！");
                    break a;
                }
            }
        }

    }
}
